package cn.hicard.risk.action.bd;

import org.apache.log4j.Logger;

import cn.hicard.risk.common.Constant;
import cn.hicard.core.Page;
import cn.hicard.core.PageResult;
import cn.hicard.risk.entity.JzgRiskestimate;
import cn.hicard.risk.service.bd.JzgRiskestimateService;

public class JzgRiskEstimateFlex {
	
	private static Logger logger = Logger.getLogger(Constant.LOGGER_MAIN);
	
	private JzgRiskestimateService jzgRiskestimateService;	

	public void setJzgRiskestimateService(
			JzgRiskestimateService jzgRiskestimateService) {
		this.jzgRiskestimateService = jzgRiskestimateService;
	}

	/**
	 * 保存商户风险评估
	 * @param estimate
	 */
	public void saveEstimate(JzgRiskestimate estimate) throws Exception {
		try {
			jzgRiskestimateService.saveEstimate(estimate);
		} catch (Exception e) {			
			logger.error("保存时发生异常",e);
			throw e;
		}
	}
	
	/**
	 * 修改商户风险评估
	 * @param estimate
	 */
	public void modifyEstimate(JzgRiskestimate estimate) throws Exception {
		try {
			jzgRiskestimateService.modifyEstimate(estimate);
		} catch (Exception e) {			
			logger.error("修改时发生异常",e);
			throw e;
		}
	}

	/**
	 * 根据ID查询单条评估信息
	 * @param estimateId
	 * @return
	 * @throws Exception 
	 */
	public JzgRiskestimate findEstimate(int estimateId) throws Exception{
		try {
			return jzgRiskestimateService.findEstimate(estimateId);
		} catch (Exception e) {
			logger.error("查询时发生异常",e);
			throw e;
		}		
	}
	
	/**
	 * 根据相应条件搜索风险评估数据集合，结果以分页显示。<br/>
	 * 如果遇到单一字段的数值区间的搜索条件时，则将数值区间的开始位设在estimateStart中，数值区间的结束位设在estimateEnd中;<br/>
	 * 如果搜索条件为单个字段，则值设在estimateStart中。
	 * @param estimateStart
	 * @param estimateEnd
	 * @param page
	 * @return
	 * @throws Exception 
	 */
	public PageResult<JzgRiskestimate> searchEstimate(
			JzgRiskestimate estimateStart,
			JzgRiskestimate estimateEnd,
			Page page
			) throws Exception{
		try {
			return jzgRiskestimateService.searchEstimate(estimateStart,estimateEnd,page);
		} catch (Exception e) {
			logger.error("搜索时发生异常",e);
			throw e;
		}
	}
	
}
